home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / rlib / mean < prev    next >
Text File  |  1995-03-20  |  512b  |  25 lines

  1. //-------------------------------------------------------------------//
  2. //
  3. //  Syntax:    mean ( A )
  4.  
  5. //  Description:
  6.  
  7. //  Calculate the mean value. If the input is a 1xN, then compute the
  8. //  mean value of all the elements. 
  9.  
  10. //  If the input is a MxN matrix the compute a row matrix of the mean
  11. //  value of each column of the input. 
  12. //
  13. //-------------------------------------------------------------------//
  14.  
  15. mean = function(x)
  16. {
  17.   m = x.nr;
  18.   if( m == 1 ) 
  19.   { 
  20.     m = x.nc;
  21.   }
  22.   
  23.   return sum( x ) / m;
  24. };
  25.